class Link(object):
    link_id=0
    length=0
    width=0
    lanes=0
    in_top=[]
    out_top=[]
    lane_width=0
    
    def __init__(self,li,le,w,la,it,ot,lw):
        self.link_id=li
        self.length=le
        self.width=w
        self.lanes=la
        self.in_top=it
        self.out_top=ot
        self.lane_width=lw

    def print_info(self):
        print 'in_top=',self.in_top,'out_top=',self.out_top
        print ('link_id=%d length=%d width=%d lanes=%d lane_width=%d'
               %(self.link_id,self.length,self.width,self.lanes,self.lane_width))

    def get_neighbor(self):
        res=[self.link_id]
        res.extend(self.in_top)
        res.extend(self.out_top)
        return res

class Links(object):
    
    def __init__(self):
        self.links=[]

    def add_link(self,link):
        if isinstance(link,Link):
            self.links.append(link)
        else:
            print 'not Link class'

    def print_info(self):
        for i in self.links:
            i.print_info()

    def find_link(self,link_id):
        for i in self.links:
            if i.link_id==link_id:
                return i
        return None


def Links_test():
    a=Links()
    b=Link(1,2,3,4,[5,6],[],7)
    print b.lanes
    a.add_link(b)
    a.add_link(1)
    a.print_info()
    a.find_link(1).print_info()
